import babel from "@babel/core"; //core包括corejs corejs用于处理新特性
import presetEnv from "@babel/preset-env"; // es6 转 es5
import react from "@babel/preset-react"; // 支持jsx
import fs from 'node:fs'

// const code = fs.readFileSync("./test.js", "utf-8")
const code = fs.readFileSync("./app.jsx", "utf-8")


// useBuiltIns: usage(按需引用)  enter(手动引用)
const result = babel.transform(code,{presets:[[presetEnv, {useBuiltIns: 'usage', corejs: 3}], react]})
console.log(result.code)